home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1996 June
/
Software of the Month Club 1996 June.iso
/
mac
/
ISO9660
/
DOS
/
DTP
/
AURORA
/
COUNTCHR.AML
< prev
next >
Wrap
Text File
|
1995-02-24
|
3KB
|
97 lines
// ───────────────────────────────────────────────────────────────────
// The Aurora Editor v2.0
// Copyright 1993-1995 nuText Systems. All Rights Reserved Worldwide.
//
// Count characters
//
// This macro counts the number of characters in current file
// or in a marked block (if one exists). The total number of
// characters reported is the number of bytes that the file or
// marked block would occupy on disk if it were saved (including
// delimiter chars).
// ───────────────────────────────────────────────────────────────────
include bootpath "define.aml"
var total_char
// edit windows only
if not wintype? "edit" then
msgbox "Edit windows only!"
return
end
// if nothing is marked, then temporarily mark the whole file
if mark? then
if getcurrbuf <> getmarkbuf then
msgbox "Mark must be in current window"
return
end
else
tempmark = TRUE // flag indicating temporary mark
markline 1 (getlines) // mark entire file
end
marktype = getmarktype // get the mark type
firstline = getmarktop // get the top line of the mark
lastline = getmarkbot // get the bottom line of the mark
currbuf (getmarkbuf) // make marked buffer the current buffer
pushcursor // save cursor position
row (getmarktop) // goto the top of the marked block
// do for all lines in the mark
repeat
total_char = total_char + // add size to total
case marktype
// line marks
when 'l'
getlinelen
// column marks
when 'k'
sizeof (gettext (getmarkleft) (getmarkcols))
// character/stream marks
otherwise
if getrow == firstline then
sizeof (gettext (getmarkleft)
(if firstline == lastline then
getmarkcols
end))
elseif getrow == lastline then
sizeof (gettext 1 (getmarkright))
else
getlinelen
end
end
until not down or getrow > lastline
// restore cursor position
popcursor
// compute the space that would be occupied by delimiter
// characters if the marked block was saved (zero for binary files)
if not getbinarylen then
delimitspace = getmarkrows * (sizeof (hex2bin _LineDlm))
end
// destroy mark if temporary
if tempmark then
destroymark
end
display
// display the totals
shortbox (if? tempmark "Entire file: " "Marked Block: ") +
(thousands total_char + delimitspace) + " chars (" +
(thousands total_char) + " text + " +
(thousands delimitspace) + " delimiter)"
"Character Count"